package com.hedl.classroom.feignclient.impl;

import com.hedl.classroom.feignclient.ContentServiceClient;
import com.hedl.classroom.model.po.CoursePublish;
import com.hedl.classroom.model.po.Teachplan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author Big Watermelon
 * @description
 * @date 2023/12/15/21:46
 */
@Slf4j
@Component
public class ContentServiceClientFallbackFactory implements FallbackFactory<ContentServiceClient> {
    @Override
    public ContentServiceClient create(Throwable cause) {
        return new ContentServiceClient() {
            @Override
            public CoursePublish getCoursepublish(Long courseId) {
                log.error("调用内容管理服务发生熔断:{}", cause.toString(),cause);
                return null;
            }

            @Override
            public Teachplan getTeachplan(Long teachplanId) {
                log.error("调用内容管理服务查询教学计划发生熔断:{}", cause.toString(),cause);
                return null;
            }
        };
    }
}
